package cn.xjt.gaoji;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 测试线程池
 * @author xujiangtao
 * @create 2020-08-02-14:42
 */
public class TestPool {     //pool:池子
    public static void main(String[] args) {
        //创建了一个大小为10的线程池
        //executor  执行者     service: 服务        fixed:确定的 pool:池子
        ExecutorService e = Executors.newFixedThreadPool(5);
        //调用execute方法开启线程
        e.execute(new MyThread());
        //execute:实行
        e.execute(new test());
        e.execute(new MyThread());
        e.execute(new MyThread());
        e.shutdown();                   //关闭线程
    }
}
class MyThread implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}

class test extends Thread{
    @Override
    public void run() {
        System.out.println("你好啊");
    }
}